package com.googlecode.bip.dao.mysql;

import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.NamingException;
import com.googlecode.bip.dao.LocalDAO;
import com.googlecode.bip.dao.utils.DBHelper;


/**
 *
 * @author Claude CHOISNET
 */
public class MySQLLocalDAO
      extends LocalDAO
{
    private static final long serialVersionUID = 1L;

    /**
     * Create a new LocalDB
     */
    public MySQLLocalDAO()
    {
    }

    @Override
    protected synchronized void loadLocalMap()
        throws NamingException, SQLException
    {
        Connection connection = MySQLDAOFactory.getConnection();

        try {
            super.setLocalMap(
                    DBHelper.getStringStringMap(
                        connection,
                        "SELECT * FROM `locals`",
                        "idlocal",
                        "name"
                        )
                    );
            }
        finally {
            MySQLDAOFactory.returnConnectionToPool( connection );
            }
    }

}
